﻿using SqlSugar;
using System.ComponentModel.DataAnnotations;

namespace Qy.Scenario;

[SugarTable(DbTableName.QyConfig)]
public class Config
{
    public string Name { get; set; }
    public string Data { get; set; }
}


public class SytemConfig
{
    /// <summary>
    /// 系统信息
    /// </summary>
    [Display(Name = "系统名称")]
    [Required(ErrorMessage = "{0}不能为空")]
    public string SiteName { get; set; }
    [Display(Name = "使用单位")]
    [Required(ErrorMessage = "{0}不能为空")]
    public string UnitOfUse { get; set; }
    [Display(Name = "系统地址")]
    [Required(ErrorMessage = "{0}不能为空")]
    public string SiteUrl { get; set; }
    [Display(Name = "系统描述")]
    [Required(ErrorMessage = "{0}不能为空")]
    public string Description { get; set; }

    [Display(Name = "系统版权")]
    [Required(ErrorMessage = "{0}不能为空")]
    public string Copyright { get; set; }
    [Display(Name = "备案号")]
    public string Beian { get; set; }
    /// <summary>
    /// 上传
    /// </summary>
    [Display(Name = "上传目录 ")]
    [Required(ErrorMessage = "{0}不能为空")]
    public string BaseDir { get; set; }

    [Display(Name = "图片目录 ")]
    public string ImageDir { get; set; }

    [Display(Name = "图片大小")]
    [RegularExpression(RegxPatterns.Number, ErrorMessage = "{0}必须为数字")]
    public int ImageSize { get; set; }

    [Display(Name = "图片类型")]
    public string ImageExt { get; set; }

    [Display(Name = "附件目录 ")]
    public string FileDir { get; set; }
    [Display(Name = "消息附件")]
    public string NoticeAttDir { get; set; }

    [Display(Name = "文件类型")]
    public string FileExt { get; set; }

    [Display(Name = "文件大小")]
    [RegularExpression(RegxPatterns.Number, ErrorMessage = "{0}必须为数字")]
    public int FileSize { get; set; }
    public bool CmsCache { get; set; }
    public int CmsCacheTime { get; set; }

    public bool ValidCodeOn { get; set; }
    public int ValidCodeType { get; set; }

    public SystemInfo AsSystemInfo()
    {
        return new SystemInfo
        {
            SiteName = SiteName,
            UnitOfUse = UnitOfUse,
            SiteUrl = SiteUrl,
            Description = Description,
            Copyright = Copyright,
            Beian = Beian,
        };
    }
    public UpLoadConfig AsUpLoadConfig()
    {
        return new UpLoadConfig
        {
            BaseDir = BaseDir,
            ImageDir = ImageDir,
            ImageSize = ImageSize,
            ImageExt = ImageExt,
            FileDir = FileDir,
            FileExt = FileExt,
            FileSize = FileSize,
        };
    }    public CacheConfig AsCacheConfig()
    {
        return new CacheConfig
        {
            CmsCache = CmsCache,
            CmsCacheTime = CmsCacheTime,
            ValidCodeOn = ValidCodeOn,
            ValidCodeType = ValidCodeType,
        };
    }
}


public class SystemInfo
{
    public string SiteName { get; set; }
    public string UnitOfUse { get; set; }
    public string SiteUrl { get; set; }
    public string Description { get; set; }
    public string Copyright { get; set; }
    public string Beian { get; set; }
};
public class UpLoadConfig
{
    public string BaseDir { get; set; }
    public string ImageDir { get; set; }
    public int ImageSize { get; set; }
    public string ImageExt { get; set; }
    public string FileDir { get; set; }
    public string FileExt { get; set; }
    public int FileSize { get; set; }
};

public class CacheConfig
{
    public bool CmsCache { get; set; }
    public int CmsCacheTime { get; set; }
    public bool ValidCodeOn { get; set; }
    public int ValidCodeType { get; set; }
};
